package com.example.mapp;

import com.example.entity.authority.MaintenancePartyDetail;
import org.apache.ibatis.annotations.*;

/**
 * Created by simon on 2017/10/1.
 */
@Mapper
public interface MaintenancePartyDetailMapp {

    @Select("select * from maintenance_party_detail where party_id=#{partyId}")
    public MaintenancePartyDetail queryById(String partyId) throws Exception;


    @Insert(" insert into maintenance_party_detail " +
            "(bus_reg_num,certified_staff_num," +
            "charge_person,contact_person,end_date," +
            "fix_office_addr,level,maintenance_elevator_num," +
            "office_person_name,office_person_phone," +
            "office_phone,org_code,party_id,phone,qualification_num," +
            "qualification_range,registered_capital,start_date," +
            "zip_code,zzjb,zzs_url,start_num) " +
            "value (#{busRegNum},#{certifiedStaffNum},#{chargePerson},#{contactPerson}," +
            "#{endDate},#{fixOfficeAddr},#{level},#{maintenanceElevatorNum},#{officePersonName}," +
            "#{officePersonPhone},#{officePhone},#{orgCode},#{partyId},#{phone},#{qualificationNum}," +
            "#{qualificationRange},#{registeredCapital},#{startDate},#{zipCode},#{zzjb},#{zzsUrl},#{startNum})")
    @SelectKey(statement="select last_insert_id()",keyProperty = "id",keyColumn = "id",before = false,resultType = Long.class)
    public int add(MaintenancePartyDetail maintenancePartyDetail) throws Exception;

    @Update(" update maintenance_party_detail set " +
            "bus_reg_num=#{busRegNum},certified_staff_num=#{certifiedStaffNum}," +
            "charge_person=#{chargePerson},contact_person=#{contactPerson},end_date=#{endDate}," +
            "fix_office_addr=#{fixOfficeAddr},level=#{level},maintenance_elevator_num=#{maintenanceElevatorNum}," +
            "office_person_name=#{officePersonName},office_person_phone=#{officePersonPhone}," +
            "office_phone=#{officePhone},org_code=#{orgCode},party_id=#{partyId},phone=#{phone},qualification_num=#{qualificationNum}," +
            "qualification_range=#{qualificationRange},registered_capital=#{registeredCapital},start_date=#{startDate}," +
            "zip_code=#{zipCode},zzjb=#{zzjb},zzs_url=#{zzsUrl},start_num=#{startNum} where id=#{id}")
    public int update(MaintenancePartyDetail maintenancePartyDetail) throws Exception;
}
